<!DOCTYPE html>
<!-- ng-app -->
<html lang="en" ng-app="app">
<head>
    <meta charset="UTF-8">
    <title>推断式注入</title>
    <script src="../../../js/plugins/angular/angular.min.js" type="text/javascript"></script>
</head>
<body>
    <div ng-controller="cont">
        <input type="button" id="btnAlert" value="弹出对话框" ng-click="onClick('我是一个弹出对话框')">
    </div>

    <script>
        var app = angular.module('app',[]).factory('$show',function ($window) {
            return {
                show : function (text) {
                    $window.alert(text);
                }
            }
        })

        var cont = function ($scope,$show) {
            $scope.onClick = function (msg) {
                $show.show(msg);
            }
        }
        app.controller('app',cont);

    </script>
</body>
</html>